Wiki

Clone wiki

md-maven / A sample Moneydance extension + Eclipse setup

I am going to show you how I set up an Eclipse env to code/debug MD extension. It will require some upfront setup work but once that is done, you will have an environment where you can

  • Work in an isolated Moneydance instance (and not your "production/day-to-day" instance)
  • You can debug, setup breakpoint. It will feel a lot more natural to have your extension code as part of your project rather than something that needs to be packaged up before it can be ran.

Prerequisite

  • You have Eclipse running (actually IntelliJ will work just as well).
  • You have Maven installed.
  • You have Moneydance jar files installed as Maven dependencies (I will show you how to do that)
  • You have an Eclipse project for your extension. We will use Mike's filedisplay extension for this example.

Moneydance jar files installed as Maven dependencies

See https://bitbucket.org/hleofxquotesteam/md-maven/wiki/Home

Source code for your extension

  • For this example, we are going to use Mike's filedisplay extension
  • Clone this Git repo
    git clone https://bitbucket.org/hleofxquotesteam/moneydance-2019.git
    
  • Manually build it (also see this wiki page)
    cd moneydance-2019
    cd maven
    mvn clean install
    

Eclipse project

Use Eclipse to import the Maven project from 'moneydance-2019/maven/filedisplay'

Start 'dev' instance of Moneydance

  • Use Eclipse debug launcher to start 'com.hleofxquotes.md.MdMavenLauncher.main()' (from src/main/java/com/hleofxquotes/md/MdMavenLauncher.java)
  • Enter your MD license as needed.
  • Install a "minimum/glue" filedisplay extension (target/dist/filedisplay-min.mxt)
  • Stop MD and restart (using MdMavenLauncher). Try to use the extension. Make sure that it is working as expected.
  • Now see if you can set a breakpoint and stop somewhere in the extension code. For example:
    ...
        private synchronized void showConsole() {
    ...
    

Tips

  • Why do we need to convert the MD jar files into Maven dependencies? It just make life easier by allowing Maven to manage those files/dependencies. Modern IDE all support Maven. The alternative is to keep them in a libs/ dir somewhere.
  • How/where we declare that we need the MD dependencies? Take a look at the pom.xml file. filedisplay's pom.xml has
      <parent>
        <groupId>org.bitbucket.mikerb.md</groupId>
        <artifactId>mikerb-maven</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </parent>
    
    which says it has a parent project 'mikerb-maven' whose pom.xml has
        <moneydance.version>2020.1917</moneydance.version>
    ...
        <dependency>
          <groupId>com.moneydance.maven</groupId>
          <artifactId>md-parent</artifactId>
          <version>${moneydance.version}</version>
          <type>pom</type>
        </dependency>
    
  • Where does 'target/dist/filedisplay-min.mxt' come from? It was created when you run (in maven/filedisplay)

    mvn install
    
    What does it do? It has enough information to register the extension BUT not including any of the class files. That way when the extension is ran, the JVM will use the classes in the Eclispe project so that you can debug and set breakpoint.

  • What happens if there is a newer version of MD? You do another 'md-maven-install'

    cd md-maven-install
    mvn clean install
    
    That will download a new MD distribution (if newer than what you already have in download/). Make a note of the version number in download/version.txt.

In 'maven/pom.xml' change

  <moneydance.version>2020.1917</moneydance.version>
to the new version number.

Updated